import { http } from '@/package_tms/utils/request.js'
import { HomeList } from './types'
enum Urls {
	storeDetail = 'driver/store/detail',
	
	storeAdd = 'driver/store/add',
	shopList = 'driver/store/list',
	shopEdit = 'driver/store/edit',
	
	orderList = 'driver/task/order_list',
	Detail = 'driver/task/order_info',
	Sign = 'driver/task/pay',
	
	
	accountList = '/driver/account/list',
	
	storeList = 'driver/task/store_list',
	
	salesmanWarehouse = 'mini/search/salesman_warehouse',
	orderReturn = 'driver/task/order_return',
	returnOrderList = 'driver/task/return_order_list',
	returnOrderDetail = 'driver/task/return_order_detail',
	createReturnOrderList = 'driver/task/create_return_order',
	// returnOrderDetail = 'mini/driver/return_order_detail',
	transferOrderList = 'driver/task/transfer_order_list',
	transferOrderDetail = 'driver/task/transfer_order_detail',
	warehouseList = 'driver/task/warehouse_list',
	upLoad = 'driver/task/upload',
	getWarehouseEntrance = 'driver/inventory/list',
	getRegionList = 'salesman/search/regionList',
	cStock = 'driver/task/is_stock_sufficient'
}

// 列表
interface ListResponse<T> extends IBaseResponse {
	data : {
		current_page : number
		data : Array<T>
		last_page : number
		per_page : number
		total : number,
		undone : number,
		done : number
	}
}
//校检库存
export const checkStock = (data) => http.post(Urls.cStock, data)
// 获取库存
export const getWarehouseEntrance = (params) => http.get(Urls.getWarehouseEntrance, params)
// 获取片区列表
export const getRegionList = () => http.get(Urls.getRegionList)
// 配送任务列表
type GetListApi = (data : Partial<ListParams>) => Promise<ListResponse<HomeList>>
export const getListApi : GetListApi = (params) => http.get(Urls.storeList, params)

// 配送订单列表
export const getOrderListApi = (params) => http.get(Urls.orderList, params)
// 详情
type DetailParams = { order_id : string }
type GetDetailApi = (data : DetailParams) => Promise<IListResponse<HomeList>>
export const getDetailApi : GetDetailApi = (params) => http.get(Urls.Detail, params)

// 签收
type SignParams = { id : string, img : string }
type SignApi = (data : SignParams) => Promise<IListResponse<HomeList>>
export const signApi : SignApi = (data) => http.post(Urls.Sign, data)

// 司机对账列表
export const accountList = (params) => http.get(Urls.accountList, params)

// 门店列表
export const shopList = (params) => http.get(Urls.shopList, params)
// 新增门店
export const storeAdd = (params) => http.post(Urls.storeAdd, params)
// 门店修改
export const shopEdit = (data) => http.post(Urls.shopEdit, data)

// 门店详情
export const storeDetail = (params) => http.get(Urls.storeDetail, params)

// 仓库列表-（主仓库、与该业务员绑定的移动仓库）
export const getWarehouseApi = () => http.get(Urls.salesmanWarehouse)

// 司机签收回库
export const orderReturn = (data) => http.post(Urls.orderReturn, data)

// 司机待创建调拨回库订单  回库单列表
export const returnOrderList = (params) => http.get(Urls.returnOrderList, params)
// 回库单详情
export const returnOrderDetail = (params) => http.get(Urls.returnOrderDetail, params)
// 批量创建调拨回库单
export const createReturnOrderList = (data) => http.post(Urls.createReturnOrderList, data)

// 司机调拨单详情
// export const returnOrderDetail = (params) => http.get(Urls.returnOrderDetail, params)

// 司机调拨单列表
export const transferOrderList = (params) => http.get(Urls.transferOrderList, params)

// 司机调拨单详情
export const transferOrderDetail = (params) => http.get(Urls.transferOrderDetail, params)

// 主仓列表
export const warehouseList = () => http.get(Urls.warehouseList)